//
//  VideoViewController.m
//  FootballSport
//
//  Created by lanou3g on 15/5/28.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "VideoViewController.h"


#import "VideoAddChildVC.h"

@interface VideoViewController ()<UIScrollViewDelegate>

@end

@implementation VideoViewController

-(instancetype)init{
    if (self = [super init]) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(execute:) name:segmentSendNotification object:nil];
    }
    return self;     
}
- (void)setupSubView{
      
        _videoScrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds),CGRectGetHeight(self.view.bounds)-44-64)];
       
        _videoScrollV.contentSize = CGSizeMake(4*CGRectGetWidth(self.view.bounds),0);
        _videoScrollV.pagingEnabled = YES;
        self.videoScrollV.delegate = self;
        self.videoScrollV.contentOffset =CGPointMake(0, 0);
        [self.view addSubview:self.videoScrollV];
        _videoScrollV.bounces =NO;
  
}




- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupSubView];
  

   
    [VideoAddChildVC getChildWithVideoVC:self];

    // Do any additional setup after loading the view.
}

- (void)execute:(NSNotification *)notification{
    
    NSNumber *number = notification.object;
    
    self.videoScrollV.contentOffset = CGPointMake(CGRectGetWidth(self.videoScrollV.bounds)*[number integerValue], 0);

    
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    
    NSNumber *number = [NSNumber numberWithInteger:(NSInteger)(self.videoScrollV.contentOffset.x/CGRectGetWidth(self.videoScrollV.bounds))];
    [[NSNotificationCenter defaultCenter] postNotificationName:scrollSendNotification object:number];
    [[NSNotificationCenter defaultCenter] postNotificationName:segmentSendNotification object:number];


    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
